package gameMechanics;

import java.util.ArrayList;
import java.util.Collections;


public class Deck {
	
	private ArrayList<String> deck;
	private BoardCards currentBoardCards;
	private CardSymbols symbols;
	
	public Deck(){
		deck = new ArrayList<String>();
		currentBoardCards = new BoardCards();
		symbols = new CardSymbols();
		for (Suit s : Suit.values()){
			for (Rank r : Rank.values()){
				deck.add(symbols.symbolFor(s, r));
			}
		}
		Collections.shuffle(deck);
	    } 
	
	public String dealCard(){
		if(deck.isEmpty()){
			deck = createNextDeck();
			for(int idx = currentBoardCards.checkBoardCards().size(); idx > 0; idx--){
				if(deck.contains(currentBoardCards.checkBoardCards().get(idx))){
					deck.remove(currentBoardCards.checkBoardCards().get(idx));
				}
			}
		}
		String s = deck.get(0);
		deck.remove(0);
		return s;
	}
	public ArrayList<String> createNextDeck(){
		this.deck = new ArrayList<String>();
		for (Suit s : Suit.values()){
			for (Rank r : Rank.values()){
				this.deck.add(symbols.symbolFor(s, r));
			}
		}
		Collections.shuffle(this.deck);
		return deck;
	}
	
	public ArrayList<String> getDeckState(){
		return deck;
	}
	
}
